<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 导入依赖 -->
    <script src='https://unpkg.com/@antv/l7'></script>
    <script src="https://lib.baomitu.com/jquery/2.2.4/jquery.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        #map {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background-color: rgba(255, 0, 0, 0.565);
        }
    </style>
</head>

<body>
    <div id="map">

    </div>
    <script>
        /* Scene场景 -L7不提供地图,只专注于地理数据可视化
        Scene 
        1、Map
        2、Layer
         */
        const scene = new L7.Scene({
            /* 设置场景的挂载点 */
            id: "map",
            map: new L7.GaodeMap({
                style: "dark",
                center: [114.30, 30.50],
                // pitch: 60,
                /* zoom可以实现放大和缩小级别 */
                zoom: 2
            }),
            logoVisible: false
        })
        /* 地图控件 */
        scene.on('loaded', () => {
            /* 地图主题控件 */
            const mapTheme = new L7.MapTheme();
            scene.addControl(mapTheme);
            let url = 'https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json'
            $.ajax({
                url,
                success: data => {
                    console.log(data);
                    var china_layer = new L7.PolygonLayer();
                    /* source+style = ol source+paint+type=mapbox */
                    /* L7  source+ */
                    china_layer.source(data)
                        /* color可以直接获取properties中的值 */
                        .color("name", ["red", "green", "yellow", "blue"])
                        .style({
                            opacity: 0.8
                        })
                        /* 鼠标悬停-图层颜色改变 */
                        // .active(true)
                        // .active({
                        //     color: "#333"
                        // })
                        .select({
                            color: "#333"
                        })
                    scene.addLayer(china_layer);

                    /* 设置线图层 -- 设置描边 */
                    const china_line = new L7.LineLayer();
                    china_line
                        .source(data)
                        .color("#ff2d51")
                        /* 可以线的宽度 */
                        .size(1)
                    scene.addLayer(china_line);
                }
            })
        });
    </script>
</body>

</html>